Add a controller method `redirect_back`

Akinori MUSHA лет %!s(int64=9): %!d(string=назад)
Родитель
Сommit
00dcc88830
1 измененных файлов с 6 добавлено и 0 удалено
  1. 6 0
      app/controllers/application_controller.rb

+ 6 - 0
app/controllers/application_controller.rb

@@ -6,6 +6,12 @@ class ApplicationController < ActionController::Base
6 6
 
7 7
   helper :all
8 8
 
9
+  def redirect_back(fallback_path, *args)
10
+    redirect_to :back, *args
11
+  rescue ActionController::RedirectBackError
12
+    redirect_to fallback_path, *args
13
+  end
14
+
9 15
   protected
10 16
 
11 17
   def configure_permitted_parameters